﻿package mortal.game.scene3D.display3d.icon3d
{
    import __AS3__.vec.*;
    import baseEngine.core.*;
    import flash.events.*;
    import flash.geom.*;
    import frEngine.*;
    import frEngine.event.*;

    public class Icon3D extends Pivot3D
    {
        private var _targetVector:Vector.<Number>;
        public var _ix:int;
        private var _iy:int;
        private var _iz:int;
        private var _iw:int;
        private var _ix2:int;
        private var _iy2:int;
        private var _iz2:int;
        private var _iw2:int;
        private var _isShowing:Boolean = false;
        public var bigImgUrl:String;
        public var xx:int = 0;
        public var yy:int = 0;
        public var xNum:int = 1;
        public var yNum:int = 1;
        private var _updataPos:Boolean = false;
        private static var _temp0:Vector3D = new Vector3D();

        public function Icon3D(param1:String)
        {
            super("");
            this.enabledPool = false;
            this.bigImgUrl = param1;
            FrEventDispatcher.instance.proxyAddEventListener(this, Engine3dEventName.VISIBLE_CHANGE_EVENT, this.visibleChangeHander);
            return;
        }// end function

        override public function dispose(param1:Boolean = true) : void
        {
            super.dispose(param1);
            FrEventDispatcher.instance.proxyRemoveEventListener(this, Engine3dEventName.VISIBLE_CHANGE_EVENT, this.visibleChangeHander);
            return;
        }// end function

        public function reInit(param1:Vector.<Number>) : void
        {
            this._targetVector = param1;
            this._ix = param1.length;
            this._iy = this._ix + 1;
            this._iz = this._ix + 2;
            this._iw = this._ix + 3;
            this._ix2 = this._ix + 4;
            this._iy2 = this._ix + 5;
            this._iz2 = this._ix + 6;
            this._iw2 = this._ix + 7;
            this._targetVector[this._ix] = 0;
            this._targetVector[this._iy] = 0;
            this._targetVector[this._iz] = 0;
            this._targetVector[this._iw] = 1;
            this._targetVector[this._ix2] = this.xNum;
            this._targetVector[this._iy2] = this.yNum;
            this._targetVector[this._iz2] = this.xx;
            this._targetVector[this._iw2] = this.yy;
            this._isShowing = true;
            this._updataPos = true;
            if (this._targetVector.length > 400)
            {
                throw new Error("超出icon3d范围");
            }
            return;
        }// end function

        override public function update(param1:int = 0) : void
        {
            var _loc_2:Vector3D = null;
            if (this._updataPos)
            {
                _loc_2 = this.getPosition(false, _temp0);
                this._targetVector[this._ix] = _loc_2.x;
                this._targetVector[this._iy] = _loc_2.y;
                this._targetVector[this._iz] = _loc_2.z;
                this._updataPos = false;
            }
            return;
        }// end function

        public function setImgPos(param1:uint, param2:uint, param3:int, param4:int) : void
        {
            if (this._targetVector)
            {
                var _loc_5:* = param3;
                this.xNum = param3;
                this._targetVector[this._ix2] = _loc_5;
                var _loc_5:* = param4;
                this.yNum = param4;
                this._targetVector[this._iy2] = _loc_5;
                var _loc_5:* = param1;
                this.xx = param1;
                this._targetVector[this._iz2] = _loc_5;
                var _loc_5:* = param2;
                this.yy = param2;
                this._targetVector[this._iw2] = _loc_5;
            }
            return;
        }// end function

        public function show() : void
        {
            this._targetVector[this._iw] = 1;
            this._isShowing = true;
            return;
        }// end function

        public function hide() : void
        {
            this._targetVector[this._iw] = -1;
            this._isShowing = false;
            return;
        }// end function

        private function visibleChangeHander(event:Event) : void
        {
            if (this.visible)
            {
                this.show();
            }
            else
            {
                this.hide();
            }
            return;
        }// end function

        override public function updateChildrenTransform(param1:int = 0) : void
        {
            this.worldTransformChanged = true;
            this._updataPos = true;
            return;
        }// end function

        override public function updateTransforms(param1:Boolean, param2:Boolean, param3:int = 0) : void
        {
            this.worldTransformChanged = true;
            var _loc_4:* = this.getPosition(false, _temp0);
            this._targetVector[this._ix] = _loc_4.x;
            this._targetVector[this._iy] = _loc_4.y;
            this._targetVector[this._iz] = _loc_4.z;
            this._updataPos = false;
            return;
        }// end function

    }
}
